<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
	<title>Ejemplo Login</title>

	<script type="text/javascript">
		function handleComplete(xhr, status, args) {
			if (args.validationFailed) {
				alert("Validation Failed");
			} else {
				alert("Autenticado" );
								
			}
		}
	</script>
</h:head>
<h:body>
	<h1>Loguin </h1>

	<h:form>
		<p:panel styleClass="session" header="Iniciar">
			<h:panelGrid columns="1">
				<h:outputLabel value="Usuario" />
				<p:inputText id="user" value="#{user.nick}" required="true"
					requiredMessage="Campo Requerido" />
				<p:message for="user" />
				<h:outputLabel value="Password"></h:outputLabel>
				<p:password id="password" required="true" value="#{user.password}"
					requiredMessage="Campo Requerido" />
				<p:message for="password" />
			</h:panelGrid>
			<h:commandButton value="Autenticar"
				action="#{user.validateUser}"
				oncomplete="handleComplete(xhr , status, args)" /> 
		</p:panel>

	</h:form>

</h:body>
</html>